package com.xyh.transaction.mapper;

import com.xyh.transaction.entity.User;
import com.xyh.transaction.entity.dto.user.SearchDto;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface UserMapper {

    @Select("select * from t_user where username = #{name} and password = #{password}")
    User findByNameAndPassword(String name, String password);

    @Select("select * from t_user where username = #{username} and is_delete = 0")
    User findByName(String username);

    int insert(User user);

    List<User> findUserByRoleId(Integer roleId);

    List<User> findAll(SearchDto searchDto);

    void deleteBatch(@Param("ids") Integer[] ids);

    Integer deleteRoleByUserIds(@Param("ids") Integer[] ids);

    void updateUserById(User user);

    void updateStatus(@Param("ids") Integer[] ids);

    void updateUserByUserName(User user);

    Integer insertRole(@Param("userId") Integer userId, @Param("roleId") Integer roleId);

    User findById(Integer userId);
}
